<?php
	include_once("./Model/Login.php");
	include_once("./Controller/HomeController.php");

	class LoginController{

		private $login;
		
		public function __construct(){
			session_start();
			$this->login = new Login();			
		}

		public function entrar(){
			include_once("./View/FormLogin.php");
		}

		public function validarLogin(){

			$usuario 		= isset($_POST["usuario"]) 		? trim($_POST["usuario"]) 		: "";
			$senha 			= isset($_POST["senha"]) 		? trim($_POST["senha"]) 		: "";

			$this->login->setUsuario($usuario);
			$this->login->setSenha($senha);

			if($this->login->getUsuario() == "admin" && $this->login->getSenha() == "admin")
			{
				$_SESSION["logado"] = true;
				$homeController = new HomeController();
				$homeController->inicio();
			}else{				
				$this->entrar();	
			}
						
		}

		public function sair(){
			$_SESSION["logado"] = false;
			$this->entrar();
		}
	}


?>